package com.ely.coupon.common.lock.annotation;


import com.ely.coupon.common.lock.enums.LockType;
import com.ely.coupon.common.lock.enums.ReadWriteLockType;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.concurrent.TimeUnit;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface DistributedLocked {
    /**
     * 锁的名称
     *
     * @return
     */
    String value() default "";

    LockType type() default LockType.REENTRANT_LOCK;

    /**
     * 读写锁类型  READ_WRITE_LOCK  有效
     *
     * @return
     */
    ReadWriteLockType readWriteType() default ReadWriteLockType.WRITE_LOCK;

    /**
     * 尝试获取锁的时间
     *
     * @return
     */
    long waitTime() default 20;

    /**
     * 释放锁的锁的时间
     *
     * @return
     */
    long leaseTime() default 10;

    /**
     * 时间单位
     *
     * @return
     */
    TimeUnit unit() default TimeUnit.SECONDS;

}
